package com.dz51.core.validate.validator.strategy;  

import javax.servlet.http.HttpServletRequest;

import com.dz51.core.validate.annotation.ParamValidater;
import com.dz51.core.validate.util.ValidateResultBulider;
import com.dz51.core.validate.vo.ValidateResult;

public class NotNullValidator extends ValidateModel{

    @Override
    public ValidateResult validate(HttpServletRequest request, ParamValidater paramValidater) {
        if(request == null || paramValidater.name() == null || paramValidater.nullable()){
            return ValidateResultBulider.createSuccessResult(request);
        }
        String param = request.getParameter(paramValidater.name());
        if(param == null || param.length() == 0){
            return ValidateResultBulider.createNoReasonFailResult(request);
        }
        return ValidateResultBulider.createSuccessResult(request);
    }

}
